#include <cstdint>
#include <cstdio>
#include <deque>
#include <iostream>
#include <istream>
#include <unordered_map>
using ll = int64_t;

const ll maxn=1007;
ll n,q,r[maxn],c[maxn];
char t[maxn];
enum Dir{
    U='U',D='D',R='R',L='L'
};
char map[maxn][maxn];
bool vis[maxn][maxn];
const int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
char idxokdir[4]={U,L,D,R};
int ans[int(2e5+7)];

#define printf

static inline ll bfs(ll x,ll y){
    printf("bfs %lld,%lld\n",x,y);
    ll res=0;
    struct P{
        ll x,y;
    };
    if(!vis[x][y])return 0;
    std::deque<P> q;
    q.emplace_back(x,y);
    while (q.size()) {
        auto[x,y]=q.front();
        printf("get %lld %lld from q\n",x,y);
        q.pop_front();
        for(ll i=0;i<4;i++){
            ll nx=x+dir[i][0],ny=y+dir[i][1];
            if(nx<1||nx>n||ny<1||ny>n||vis[nx][ny]){
                // printf("check %lld %lld not ok\n",nx,ny);
                continue;
            }
            // printf("%lld %lld should be %c, but is %c\n",nx,ny,idxokdir[i],map[nx][ny]);
            if(map[nx][ny]==idxokdir[i]||map[nx][ny]==0){
                printf("ok %lld %lld\n",nx,ny);
                q.emplace_back(nx,ny);
                vis[nx][ny]=true;
                res++;
            }
        }
    }
    printf("---out bfs\n");
    return res;
}

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>n>>q;
    for(ll i=1;i<=q;i++){
        std::cin>>r[i]>>c[i]>>t[i];
        map[r[i]][c[i]]=t[i];
    }
    ll firstans=0;
    for(ll i=1;i<=n;i++){
        vis[0][i]=1;
        vis[n+1][i]=1;
        vis[i][0]=1;
        vis[i][n+1]=1;
        firstans+=bfs(0, i);
        firstans+=bfs(n+1,i);
        firstans+=bfs(i,0);
        firstans+=bfs(i, n+1);
    }
    ans[q]=n*n-firstans;
    printf("START for loop\n");
    for(ll i=q;i>=2;i--){
        printf("FOR i=%lld\n",i);
        map[r[i]][c[i]]=0;
        for(ll j=0;j<4;j++){
            firstans+=bfs(r[i]+dir[j][0], c[i]+dir[j][1]);
        }
        ans[i-1]=n*n-firstans;
    }
    for(ll i=1;i<=q;i++){
        std::cout<<ans[i]<<"\n";
    }
}